import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DemandsVO, DemandsForm, DemandsQuery } from '@/api/business/demands/types';
import { AuditBo } from '@/api/business/services/types';

/**
 * 查询需求信息列表
 * @param query
 * @returns {*}
 */

export const listDemands = (query?: DemandsQuery): AxiosPromise<DemandsVO[]> => {
  return request({
    url: '/system/demands/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询需求信息详细
 * @param id
 */
export const getDemands = (id: string | number): AxiosPromise<DemandsVO> => {
  return request({
    url: '/system/demands/' + id,
    method: 'get'
  });
};

/**
 * 新增需求信息
 * @param data
 */
export const addDemands = (data: DemandsForm) => {
  return request({
    url: '/system/demands',
    method: 'post',
    data: data
  });
};

/**
 * 修改需求信息
 * @param data
 */
export const updateDemands = (data: DemandsForm) => {
  return request({
    url: '/system/demands',
    method: 'put',
    data: data
  });
};

/**
 * 删除需求信息
 * @param id
 */
export const delDemands = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/demands/' + id,
    method: 'delete'
  });
};

// 审核服务
export function auditDemands(data: AuditBo) {
  return request({
    url: '/system/demands/audit',
    method: 'post',
    data: data
  });
}
